﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>导出excel</title>
    <link href="/js/css/layui.css" rel="stylesheet" />
    <script src='/js/layui.js'></script>
    <script src='/js/jquery-1.10.2.js'></script>
</head>
<body>
    
    <input id="Button1" type="button" value="导出" onclick="exportExcel();" />
    <script>
        function exportExcel() {
            //调用
            layui.config({
                base: '/js/excel/'
            }).use(['excel'], function () {
                var excel = layui.excel;
                var dataList = [];
                var datatitle = ["列1", "列2", "列3"];
                var datavalue = [["1-1", "1-2", "1-3"], ["2-1", "2-2", "2-3"]];



                //创建标头
                dataList.push(datatitle);

                //创建数据
                for (var i in datavalue) {
                    dataList.push(datavalue[i]);
                }

                excel.downloadExcel(dataList, "导出标题", 'xlsx');


            });
        }
       




    </script>
</body>
</html>